package com.tmser.manager.action;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.PropertyConfigurator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.tmser.core.search.OPUtils;
import com.tmser.core.search.SearchCondition;
import com.tmser.core.search.SearchModel;
import com.tmser.model.bo.TmsAdmin;
import com.tmser.service.TmsAdminService;


public class TestM {

	public static void main(String[] args) {
		PropertyConfigurator.configure("F:\\workspace\\tms\\WebRoot\\WEB-INF\\config\\log\\log4j.properties");
		String[] locations = new String[]{
				"F:\\workspace\\tms\\WebRoot\\WEB-INF\\config\\spring\\testApplication-init.xml",
				"F:\\workspace\\tms\\WebRoot\\WEB-INF\\config\\spring\\application-manager.xml"
		};
		ApplicationContext ctx = new FileSystemXmlApplicationContext(locations);
		TmsAdminService userManager =(TmsAdminService) ctx.getBean("tmsAdminManager");
	//	TmsAdmin ta = userManager.get(1);
	//	System.out.println(ta.getUsername());
		List<SearchModel> condition = new ArrayList<SearchModel>();
		SearchCondition.addCondition(condition,"username", OPUtils.LIKE, "tjx%");
		SearchCondition.printConditions(condition);
		List us = userManager.getTmsAdmins("new TmsAdmin(id,username,realname)",condition, "a.id", 0);
		System.out.println(us.size());
		if(us.size()>0){
			System.out.println(((TmsAdmin) us.get(0)).getRealname());
		}
	}
}
